package com.woniu.humanresource.service.impl;


import com.woniu.humanresource.dao.JobCategoryDao;
import com.woniu.humanresource.entity.JobCategory;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.service.JobCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class JobCategoryServiceImpl implements JobCategoryService {

    @Resource
    JobCategoryDao jobCategoryDao;


    @Override
    public void insertJobCategory(JobCategory jobCategory) {
        jobCategoryDao.insertJobCategory(jobCategory);
    }

    @Override
    public PageBean<JobCategory> getAllJobCategory(int pageIndex, int pageSize) {
        // 查询所有职位类别集合
        List<JobCategory> allJobCategory = jobCategoryDao.selectAllJobCategory( pageIndex, pageSize);
        // 封装为pageBean对象
        PageBean<JobCategory> allJobCategorypageBean = new PageBean<>();
        allJobCategorypageBean.setBeanList(allJobCategory);
        allJobCategorypageBean.setPageIndex(pageIndex);
        allJobCategorypageBean.setPageSize(pageSize);
        allJobCategorypageBean.setBeginEnd();
        allJobCategorypageBean.setTotalRecord(jobCategoryDao.selectJobCategoryCount());
        return allJobCategorypageBean;
    }

    @Override
    public void updateJobCategory(JobCategory jobCategory, String position) {
        jobCategoryDao.updateJobCategory(jobCategory,position);
    }

    @Override
    public void deleteJobcateApplyByPosition(String position) {
        jobCategoryDao.deleteApplyByPosition(position);
    }

    @Override
    public PageBean<JobCategory> getJobCategory(JobCategory jobCategory, int pageIndex, int pageSize) {
        // 查询所有职位类别集合
        List<JobCategory> jobCategoryList = jobCategoryDao.selectJobCategory(jobCategory,pageIndex,pageSize);
        // 封装为pageBean对象
        PageBean<JobCategory> jobCategorypageBean = new PageBean<>();
        jobCategorypageBean.setBeanList(jobCategoryList);
        jobCategorypageBean.setPageIndex(pageIndex);
        jobCategorypageBean.setPageSize(pageSize);
        jobCategorypageBean.setBeginEnd();
        jobCategorypageBean.setTotalRecord(jobCategoryDao.selctJobCategoryCounts(jobCategory));
        return jobCategorypageBean;
    }
}
